<?php
/**
 * @link http://forum.php-ids.org/comments.php?DiscussionID=113 PHPIDS forum
 */
class Plugin_PHPIDS extends Zend_Controller_Plugin_Abstract
{

    public function preDispatch(Zend_Controller_Request_Abstract $request)
    {
        $request = array('GET'    => $request->getQuery(),
                         'POST'   => $request->getPost(),
                         'COOKIE' => $request->getCookie(),
                         'PARAMS' => $request->getUserParams() );
        
        $init = IDS_Init::init(APPLICATION_PATH . '/configs/phpids.ini');        
        
        $init->config['General']['base_path'] = realpath(APPLICATION_PATH . '/../library/IDS/') . '/';
        $init->config['General']['use_base_path'] = true;                
        
        $ids = new IDS_Monitor($request, $init);
        
        $result = $ids->run();
        if (!$result->isEmpty()) {
            $compositeLog = new IDS_Log_Composite();
            $compositeLog->addLogger(IDS_Log_Database::getInstance($init));
            $compositeLog->execute($result);            
        }
    }

}